<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model"  :rules="validatorRules" slot="detail">
        <!-- useful_auto_generate_section_start -->
        
        <a-row>
          <a-col :span="0.857">
            <a-form-model-item label="名称"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.name" placeholder="请输入名称" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="美国音标"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.usPhoneticSymbol" placeholder="请输入美国音标" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="英国音标"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.ukPhoneticSymbol" placeholder="请输入英国音标" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="美国发音"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.usPronunciation" placeholder="请输入美国发音" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="英国发音"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.ukPronunciation" placeholder="请输入英国发音" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="等级标签"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.levelTags" placeholder="请输入等级标签" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="名词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.noun" placeholder="请输入名词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="代词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.pron" placeholder="请输入代词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="形容词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.adj" placeholder="请输入形容词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="副词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.adv" placeholder="请输入副词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="动词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.verb" placeholder="请输入动词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="数词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.num" placeholder="请输入数词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="冠词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.art" placeholder="请输入冠词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="介词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.prep" placeholder="请输入介词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="连词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.conj" placeholder="请输入连词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="感叹词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.interj" placeholder="请输入感叹词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="名词复数"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.nounPlural" placeholder="请输入名词复数" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="第三人称单数"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.thirdSingle" placeholder="请输入第三人称单数" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="现在分词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.participle" placeholder="请输入现在分词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="过去式"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.pastTense" placeholder="请输入过去式" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="过去分词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.pastParticiple" placeholder="请输入过去分词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="类型"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-select v-model="model.type" :options="typeOptions"  />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="缩写"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.abbr" placeholder="请输入缩写" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="助动词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.aux" placeholder="请输入助动词" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="其他注释"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.otherComment" placeholder="请输入其他注释" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="比较级"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.comparative" placeholder="请输入比较级" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="最高级"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.superlative" placeholder="请输入最高级" />
            </a-form-model-item>
          </a-col>
          <a-col :span="0.857">
            <a-form-model-item label="限定词"  :labelCol="labelCol_28" :wrapperCol="wrapperCol_28" >
              <a-input v-model="model.det" placeholder="请输入限定词" />
            </a-form-model-item>
          </a-col>
        </a-row>
      <!-- useful_auto_generate_section_end -->

      </a-form-model>
    </j-form-container>
  </a-spin>
</template>


<script>

  import { httpAction, getAction } from '@/api/manage'
  import { getDataOptionList } from '@/utils/util'
  import ATextarea from 'ant-design-vue/es/input/TextArea'
  import JUpload from '@/components/jeecg/JUpload'
  import { FormMixin } from '@/mixins/FormMixin'
  import { requestSetData, requestSetOptions } from '@/utils/commonUtils'
  import moment from 'moment'

  export default {
    name: 'WordDictForm',
    mixins: [ FormMixin],
    components: {
      ATextarea
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        confirmLoading: false,
        validatorRules: {
        },
        //useful_auto_generate_section_start
        typeOptions:getDataOptionList('wordDictTypeEnum'),
        //useful_auto_generate_section_end
        url: {
          add: "/english/wordDict/save",
          edit: "/english/wordDict/update",
          queryById: "/english/wordDict/detail"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
      let $this = this;
      //useful_auto_generate_section_start
      
      //useful_auto_generate_section_end

       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));


    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      handleChange(value) {
        // console.log(`selected `);
      },
      onChange(e) {
        console.log('radio1 checked', e.target.value);
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid=>{
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            if(!this.model.id){
              httpurl+=this.url.add;
            }else{
              httpurl+=this.url.edit;
            }
            httpAction(httpurl,this.model,"post").then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>
